﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Forms;

namespace RadiationUI
{
    public class WindowManager
    {
        private static WindowManager m_manager;

        public static void Init()
        {
            m_manager = new WindowManager();
        }

        public static WindowManager Instance
        {
            get
            {
                return m_manager;
            }
        }

        // dynamic part 

        private Hashtable m_windows;

        public WindowManager()
        {
            m_windows = new Hashtable();
        }

        public ChatWindows this[string name]
        {
            get
            {
                if (m_windows.ContainsKey(name))
                    return (ChatWindows)m_windows[name];
                else
                    return null;
            }
        }

        public bool addChannel(string name, Form parent)
        {
            if (m_windows.ContainsKey(name))
                return false;
            else
            {
                m_windows.Add(name, new ChatWindows(name));
                ((Form)m_windows[name]).MdiParent = parent;
                return true;
            }
        }

        public bool removeChannel(string name)
        {
            if (!m_windows.ContainsKey(name))
                return false;
            else
            {
                m_windows.Remove(name);
                return true;
            }
        }
    }
}
